<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../lib/respond.min.js?rev=@@hash"></script>
    <![endif]-->
    <!--引入分页-->
    <link rel="stylesheet" href="../../lib/pagination/pagination.css">
    <link rel="stylesheet" type="text/css" href="../../static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="../../lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/style.css"/>
    <!--表单验证-->
    <link rel="stylesheet" type="text/css" href="../../lib/Validform/5.3.2/style.css" />
    <link rel="stylesheet" type="text/css" href="../../ht-css/Project.css"/>
    <link rel="stylesheet" href="../../ht-css/combo.select.css">
    <!--[if IE 6]>
    <script type="text/javascript" src="../../lib/DD_belatedPNG_0.0.8a-min.js?rev=@@hash"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../../ht-css/style-q.css"/>
    <title>添加SPU</title>
</head>
<body>
<nav class="breadcrumb">商品管理 <span class="c-gray en">&gt;</span> 分类/品牌设置 <span class="c-gray en">&gt;</span> 商品售卖管理 <span class="c-gray en">&gt;</span> SPU添加 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<article class="page-container">
    <form class="ml-20 mr-20" id="spu"    method="post">
        <div class="ml-20 mr-20" id="spuInfo" method="post">
            <div id="tab_topnav" class="HuiTab">
                <div class="tabCon bg-1 bk-gray pd-20 mb-20">
                    <div class="va-m lh-20 f-16 pb-15">
                        <strong>基本信息</strong>
                    </div>
                    <div class="line"></div>
                    <div class="pd-20">
                        <div class="clearfix mb-15">
                            <span class="c-red pr-5 f-l">*</span><label class="f-l">商品名称：</label>
                            <div class="formControls col-sm-5">
                                <textarea onblur="isNull()" class="textarea" id="goodsName" name="goodsName"></textarea>
                                <span class="errorMsg hide" style="color: red;">名称不能为空</span>
                            </div>
                        </div>
                        <div class="clearfix mb-15">
                            <span class="c-red pr-5 f-l">&nbsp;</span><label class="f-l">商品别名：</label>
                            <div class="f-l col-2-1">
                                <div class="clearfix mb-5" id="anotherNameBox">
                                    <div id="inpBox">

                                    </div>
                                    <a href="##" onclick="nameAdd()">添加</a>
                                </div>
                            </div>
                        </div>
                        <div class="clearfix mb-15">
                            <span class="c-red pr-5 f-l">*</span>
                            <label class="f-l">所属品牌：</label>
                            <span class="f-l">
                                    <span class="pd-15" id="brandName" name=""></span>
                                    <span class="brandErrorMsg hide" style="color: red;">名称不能为空</span>
                                    <span id="brandId" style="display:none;"></span>
                                    <a onclick="selectBrand()" class="btn btn-secondary radius size-S botter">选择</a>
                                </span>
                            <div id="selectInp" class="ml-15 f-l" style="display:none;">
                                <div style="position: relative" class="f-l">
                                    <input type="text" class="input-text radius"  name="moli" onfocus="myFunction()"  placeholder="" oninput="myFunction()" id="username" autocomplete="off">
                                    <ul class="relation radius guanlian" id="tuan">
                                        <li>无数据</li>
                                    </ul>
                                </div>
                                <a class="pd-5 f-l ml-10" onclick="brand_sure()">确定</a>
                                <a class="pd-5 f-l" onclick="brand_cancel()">取消</a>
                            </div>
                        </div>
                        <div class="clearfix mb-15">
                            <label class="f-l">商品副标题：</label>
                            <div class="formControls col-sm-5"><textarea name="" class="textarea" id="subtitile"></textarea></div>
                            <span class="subtitileErrorMsg hide" style="color: red;">超出字符限制</span>
                        </div>
                        <div class="clearfix mb-15">
                            <span class="c-red pr-5 f-l">*</span>
                            <label class="f-l">所属分类：</label>
                            <div class="cl clearfix pl-20 pt-15">
                                <div class="f-l">
                                    <div class="size-M radius mb-10">
                                        <div style="position:relative;z-index: 920;">
                                            <input type="text" autocomplete="off" class="input-text radius" name="class1" placeholder="请选择一级分类" oninput="goods_listCategory(1)" id="class1" datatype="/^[a-zA-Z0-9\u4e00-\u9fa5、]{1,20}$/" errormsg="格式错误，请重新输入" nullmsg="请填写信息">
                                            <ul class="relation radius guanlian" id="classUl1">
                                            </ul>
                                        </div>
                                        <span class="Validform_checktip"></span>
                                    </div>
                                    <div class="size-M radius mb-10">
                                        <div style="position:relative;z-index: 910;">
                                            <input type="text" autocomplete="off" class="input-text radius"  name="class2"  placeholder="请选择二级分类" id="class2" datatype="/^[a-zA-Z0-9\u4e00-\u9fa5、]{1,20}$/" errormsg="格式错误，请重新输入" nullmsg="请填写信息">
                                            <ul class="relation radius guanlian" id="classUl2">
                                            </ul>
                                        </div>
                                        <span class="Validform_checktip"></span>
                                    </div>
                                    <div class="size-M radius mb-10">
                                        <div style="position: relative;z-index: 900;">
                                            <input type="text" autocomplete="off" class="input-text radius"  name="class3" placeholder="请选择三级分类" id="class3" datatype="/^[a-zA-Z0-9\u4e00-\u9fa5、]{1,20}$/" errormsg="格式错误，请重新输入" nullmsg="请填写信息">
                                            <ul class="relation radius guanlian" id="classUl3">
                                            </ul>
                                        </div>
                                        <span class="Validform_checktip"></span>
                                    </div>
                                </div>
                            </div>
                            <span id="categoryName"></span>
                        </div>
                        <div class="clearfix mb-15">
                            <span class="c-red pr-10 f-l">&nbsp;</span><label class="f-l">商品属性：</label>
                            <div class="f-l col-2-1">
                                <div class="clearfix mb-5" id="attributeBoxs">
                                    <div class="formControls col-sm-9 f-l attributeInp" style="display: none">
                                        <span class="select-box size-M radius col-xs-8 ml-10" style="width: 35%">
                                            <select class="select" id="attributeType" size="1">
                                                <option value="-1" selected>---请选择---</option>
                                                <option value="0">销售属性</option>
                                                <option value="1">商品描述属性</option>
                                            </select>
                                        </span>
                                        <span>
                                            <input type="text" class="input-text radius f-l" id="tuansName" onfocus="selectAttribute()" name="moli" placeholder="" oninput="selectAttribute()" style="width: 30%; margin-left: 15px;" autocomplete="off">
                                            <ul class="relation radius guanlian" id="tuans" style="left: 41%; width: 130px;">
                                                <li>无数据</li>
                                            </ul>
                                        </span>
                                        <a href="#" onclick="attrDelete()" class="ml-20 f-l">删除</a>
                                    </div>
                                    <a href="###" onclick="attributeAdds()">添加</a>
                                </div>
                            </div>
                        </div>
                        <div class="clearfix mb-15"><label class="f-l">是否限制类：</label>
                            <span id="categoryName2" class="select-box size-M radius col-xs-8 ml-10" style="width: 30%">
                                    <select class="select" id="isLimitCategory" name="isLimitCategory" size="1">
                                        <option value="-1" selected>---请选择---</option>
                                        <option value="0">非限制类</option>
                                         <option value="1">危化品</option>
                                         <option value="2">管制刀具</option>
                                    </select>
                                </span>
                        </div>
                        <div class="clearfix mb-15"><span class="pr-5 f-l">&nbsp;&nbsp;</span><label class="f-l">商品标准：</label>
                            <span id="categoryName3" class="select-box size-M radius col-xs-8 ml-10" style="width: 30%">
                                    <select class="select" id="spuStandards" name="spuStandards" size="1">
                                         <option value="0" selected>不限</option>
                                         <option value="1">国标</option>
                                         <option value="2">无标准无下差</option>
                                         <option value="3">无标准有下差</option>
                                         <option value="4">其他</option>
                                    </select>
                                </span>

                        </div>
                        <div class="clearfix mb-15"><span class="pr-5 f-l">&nbsp;&nbsp;</span><label class="f-l">客户类型：</label>
                            <div class="formControls col-sm-5  ml-8">
                                <label><input type="checkbox" value="2" name="customerType"/>普通客户&nbsp;&nbsp;</label>
                                <label><input type="checkbox" value="1" name="customerType"/>签约客户</label>
                            </div>
                        </div>
                        <div class="clearfix mb-15"><span class="c-red pr-5 f-l">*</span><label class="f-l">售卖信息：</label>
                            <div class="formControls col-sm-5  ml-8">
                                <label><input type="radio" value="1" name="saleArea"/>集团&nbsp;&nbsp;</label>
                                <label><input type="radio" value="2" name="saleArea"/>北京独有&nbsp;&nbsp;</label>
                                <label><input type="radio" value="3" name="saleArea"/>天津独有&nbsp;&nbsp;</label>
                                <label><input type="radio" value="4" name="saleArea"/>郑州独有&nbsp;&nbsp;</label>
                            </div>
                        </div>
                    </div>
                    <div class="va-m lh-20 f-16 pb-15">
                        <strong>图片信息</strong>
                    </div>
                    <div class="line"></div>
                    <div class="mt-15 mb-30 imgTable clearfix">
                        <ul class="imgboxUl f-l">

                        </ul>
                        <ul class="f-l ml-5 addSpuImgbox">
                            <li class="col-5-1 text-c va-t">
                                    <span id="addSpuImg" class="spu_add_img">

                                    </span>
                            </li>
                        </ul>
                    </div>
                    <div class="va-m lh-20 f-16 pb-15">
                        <strong>详情信息</strong>
                    </div>
                    <div class="line"></div>
                    <div class="pd-20">
                        <!--<script id="editor" type="text/plain" style="width: 100%; height: 500px;"></script>-->
                    </div>
                    <div class="text-c mb-10">
                        <input id="sureBtn" type="button" onclick="makeSure()" class="btn btn-secondary radius size-S botter" value="&nbsp;确&nbsp;&nbsp;认&nbsp;">
                        <input type="button" class="btn radius size-S botter ml-10" onclick="cancleSpu()" value="&nbsp;取&nbsp;&nbsp;消&nbsp;">
                    </div>
                </div>
            </div>
        </div>
    </form>
</article>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script> <!--/_footer 作为公共模版分离出去-->
<!--表单验证-->
<script type="text/javascript" src="../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/Validform/5.3.2/Validform_v5.3.2_min.js?rev=@@hash"></script>
<script src="../../lib/pagination/jquery.pagination.js?rev=@@hash"></script>
<script src="../../ht-js/coupon/coupon-topic.js?rev=@@hash"></script>
<script src="../../ht-js/frame/doT.min.js?rev=@@hash"></script>
<script src="../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../ht-js/verifyToken.js?rev=@@hash"></script>
<script src="../../ht-js/goods/spu-add.js?rev=@@hash"></script>
<!--富文本编辑器-->
<script type="text/javascript" charset="utf-8" src="../../lib/ueditor/1.4.3/ueditor.config.js?rev=@@hash"></script>
<script type="text/javascript" charset="utf-8" src="../../lib/ueditor/1.4.3/ueditor.all.min.js?rev=@@hash"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="../../lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js?rev=@@hash"></script>

<script>
    sessionStorage.setItem("isSave", 0);// 修改是1 添加是0
    /*-----------------------图片加载处理开始-------------------------*/
    var spuInfo = {};
    spuInfo.spu_img = [];
    sessionStorage.setItem("spuInfo", JSON.stringify(spuInfo));
    $("#addSpuImg").click(function () {
        console.log('添加图片');
        if(sessionStorage.getItem("spuImgCache")){
            var spuInfoImg = JSON.parse(sessionStorage.getItem("spuImgCache"));
            var spuInfoImgArr = Object.keys(spuInfoImg);
            addPic((spuInfoImgArr.length+1), true);
        }
    });
    if(sessionStorage.getItem("spuImgCache")){
        var spuInfoImg = JSON.parse(sessionStorage.getItem("spuImgCache"));
        for(item in spuInfoImg) {
            if(item.endWith("1")){
                $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg1" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId1" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl1" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox1" class="pt-10 updataBtn"><a onclick="editPic(1, false)" class="pd-20">修改</a><a onclick="deletePic(1)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 1)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort1" name="imgSort" style="width:40px"></div></div>')
            }if(item.endWith("2")){
                $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg2" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId2" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl2" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox2" class="pt-10 updataBtn"><a onclick="editPic(2, false)" class="pd-20">修改</a><a onclick="deletePic(2)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 2)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort2" name="imgSort" style="width:40px"></div></div>')
            }if(item.endWith("3")){
                $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg3" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId3" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl3" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox3" class="pt-10 updataBtn"><a onclick="editPic(3, false)" class="pd-20">修改</a><a onclick="deletePic(3)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 3)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort3" name="imgSort" style="width:40px"></div></div>')
            }if(item.endWith("4")){
                $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg4" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId4" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl4" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox4" class="pt-10 updataBtn"><a onclick="editPic(4, false)" class="pd-20">修改</a><a onclick="deletePic(4)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 4)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort4" name="imgSort" style="width:40px"></div></div>')
            }if(item.endWith("5")){
                $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg5" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId5" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl5" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox5" class="pt-10 updataBtn"><a onclick="editPic(5, false)" class="pd-20">修改</a><a onclick="deletePic(5)" class="pd-20">删除</a></div><div class="pd-20">排序&nbsp;&nbsp;&nbsp;<input type="text" class="input-text radius" onchange="checkRepeat(this, 5)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort5" name="imgSort" style="width:40px"></div></div>');
                $(".addSpuImgbox").css({
                    display:"none"
                })
            }
        }
    } else {
        var spuImgCache = {};
        sessionStorage.setItem("spuImgCache", JSON.stringify(spuImgCache));
    }
    /*-----------------------图片加载处理结束-------------------------*/

    var skuFormData = new FormData();
    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor',{
        toolbars: [
        [
            'source', //源代码
            'anchor', //锚点
            'undo', //撤销
            'redo', //重做
            'bold', //加粗
            'indent', //首行缩进
            // 'snapscreen', //截图
            'italic', //斜体
            'underline', //下划线
            'strikethrough', //删除线
            'subscript', //下标
            'fontborder', //字符边框
            'superscript', //上标
            'formatmatch', //格式刷

            'blockquote', //引用
            'pasteplain', //纯文本粘贴模式
            'selectall', //全选
            'print', //打印
            'preview', //预览
            'horizontal', //分隔线
            'removeformat', //清除格式
            'time', //时间
            'date', //日期
            'unlink', //取消链接
            'insertrow', //前插入行
            'insertcol', //前插入列
            'mergeright', //右合并单元格
            'mergedown', //下合并单元格
            'deleterow', //删除行
            'deletecol', //删除列
            'splittorows', //拆分成行
            'splittocols', //拆分成列
            'splittocells', //完全拆分单元格
            'deletecaption', //删除表格标题
            'inserttitle', //插入标题
            'mergecells', //合并多个单元格
            'deletetable', //删除表格
            'cleardoc', //清空文档
            'insertparagraphbeforetable', //”表格前插入行”
            'insertcode', //代码语言
            'fontfamily', //字体
            'fontsize', //字号
            'paragraph', //段落格式
            /*'simpleupload', //单图上传
            'insertimage', //多图上传*/
            'edittable', //表格属性
            'edittd', //单元格属性
            'link', //超链接
            'emotion', //表情
            'spechars', //特殊字符
            'searchreplace', //查询替换
            'map', //Baidu地图
            'gmap', //Google地图
            'insertvideo', //视频
            'help', //帮助
            'justifyleft', //居左对齐
            'justifyright', //居右对齐
            'justifycenter', //居中对齐
            'justifyjustify', //两端对齐
            'forecolor', //字体颜色
            'backcolor', //背景色
            'insertorderedlist', //有序列表
            'insertunorderedlist', //无序列表
            'fullscreen', //全屏
            'directionalityltr', //从左向右输入
            'directionalityrtl', //从右向左输入
            'rowspacingtop', //段前距
            'rowspacingbottom', //段后距
            'pagebreak', //分页
            'insertframe', //插入Iframe
            'imagenone', //默认
            'imageleft', //左浮动
            'imageright', //右浮动
            // 'attachment', //附件
            'imagecenter', //居中
            'wordimage', //图片转存
            'lineheight', //行间距
            'edittip ', //编辑提示
            'customstyle', //自定义标题
            'autotypeset', //自动排版
            'webapp', //百度应用
            'touppercase', //字母大写
            'tolowercase', //字母小写
            'background', //背景
            'template', //模板
            'scrawl', //涂鸦
            'music', //音乐
            'inserttable', //插入表格
            'drafts', // 从草稿箱加载
            // 'charts', // 图表
        ]
    ]
    });
    UE.registerUI('dialog',function(editor,uiName){
        sessionStorage.setItem("category_ids", oneCategoryId + "," + twoCategoryId + "," + threeCategoryId);
        sessionStorage.setItem("skuOrSpu", "spu");
        //创建dialog
        var dialog = new UE.ui.Dialog({
            //指定弹出层中页面的路径，这里只能支持页面,因为跟addCustomizeDialog.js相同目录，所以无需加路径
            iframeUrl:'spuPictures.html',
            //需要指定当前的编辑器实例
            editor:editor,
            //指定dialog的名字
            name:uiName,
            //dialog的标题
            title:"请选择图片",
            //指定dialog的外围样式
            cssRules:"width:1000px;height:500px;",
            //如果给出了buttons就代表dialog有确定和取消
            buttons:[
                {
                    className:'edui-okbutton',
                    label:'确定',
                    onclick:function () {
                        var selectNum = sessionStorage.getItem("selectNum");
                        if (selectNum != null) {
                            var selectPic = JSON.parse(sessionStorage.getItem("selectPic"));
                            var value = "";
                            for (var i = 0; i < selectPic.length; i++) {
                                value += "<img src='" + selectPic[i] + "'>"
                            }
                            UE.getEditor('editor').execCommand('insertHtml', value)
                            sessionStorage.removeItem("selectNum");
                            sessionStorage.removeItem("selectPic");
                            dialog.close(true);
                        } else {
                            if(skuFormData!=null){
                                $.ajax({
                                    url: root.goodsInter.goods_saveImg,
                                    cache: false,  //禁用缓存
                                    type: "POST",
                                    // 告诉jQuery不要去处理发送的数据
                                    processData: false,
                                    // 告诉jQuery不要去设置Content-Type请求头
                                    contentType: false,
                                    data: skuFormData,
                                    success: function (data) {
                                        if (data.errorCode == 0) {
                                            var value = "<img src='" + data.oneImg.img_url + "'>"
                                            UE.getEditor('editor').execCommand('insertHtml', value)
                                            dialog.close(true);
                                        }
                                    }
                                });
                            }
                        }

                    }
                },
                {
                    className:'edui-cancelbutton',
                    label:'取消',
                    onclick:function () {
                        sessionStorage.removeItem("selectNum");
                        sessionStorage.removeItem("selectPic");
                        dialog.close(false);
                    }
                }
            ]
        });
        //参考addCustomizeButton.js
        var btn = new UE.ui.Button({
            name:'上传图片',
            title:'上传图片',
            //需要添加的额外样式，指定icon图标，这里默认使用一个重复的icon
            cssRules :'background-position: -726px -77px;',
            onclick:function () {
                //渲染dialog
                dialog.render();
                dialog.open();
            }
        });
        return btn;
    }
    /*index 指定添加到工具栏上的那个位置，默认时追加到最后,editorId 指定这个UI是那个编辑器实例上的，默认是页面上所有的编辑器都会添加这个按钮*/);

    /*$.ajax({
    type: "POST",
    url: root.goodsInter.goods_getSpuDetail,
    cache: false,  //禁用缓存
    dataType: "json",
    data: {
    spuId: spuId
    },
    success: function (result) {
    console.log(result)
    if (result.errorCode == 0) {
    sessionStorage.setItem("spuInfo",JSON.stringify(result));
    var spuResult = JSON.parse(sessionStorage.getItem("spuInfo"));
    $("#spu_code").html(spuResult.spu.spu_code);
    $("#goodsName").html(spuResult.spu.name);
    if(sessionStorage.getItem("alias_value")){
    $("#another_name").html(spuResult.alias.alias_value);
    }else {
    for(var i=0;i<spuResult.alias.length;i++){
        $("#inpBox").append('<div class="formControls col-sm-9 f-l aliasInp"><input type="text" class="input-text radius f-l another_name" value="'+spuResult.alias[i].alias_value+'" name="another_name" style="width: 85%"><a onclick="nameDelete(this)" class="ml-20 f-l">删除</a></div>');
    }
    }
    if(sessionStorage.getItem("brand_name")){
    $("#brandName").html(sessionStorage.getItem("brand_name"));
    $("#brandId").html(sessionStorage.getItem("brand_id"));
    }else {
    $("#brandId").html(spuResult.spu.brand_id);
    $("#brandName").html(spuResult.spu.brand_name);
    }
    $("#subtitile").val(spuResult.spu.subtitile);
    $("#categoryName").html(spuResult.spu.category_name);
    $("#brand").html(spuResult.spu.brand_name);
    $("#pack_list").html(spuResult.spu.pack_list);
    $("#texture").html(spuResult.spu.material);
    $("#expirationDate").html(spuResult.spu.guarantee_period);
    $("#productionStandard").html(spuResult.spu.standards);
    $("#productionPlace").html(spuResult.spu.origin);
    setTimeout(function(){
    UE.getEditor('editor').setContent(spuResult.spu.detail,true);
    },200);
    if(sessionStorage.getItem("attrObjCanch")){
    var attrObjCanch = JSON.parse(sessionStorage.getItem("attrObjCanch"));
    for(var i=0;i<attrObjCanch.length;i++){
        var attrValStr="";
        var attrIdsStr="";
        if(attrObjCanch[i].value.length != 0){
            for(var j=0;j<attrObjCanch[i].value.length;j++){
                attrValStr += attrObjCanch[i].value[j].attri_value+";";
                attrIdsStr +=attrObjCanch[i].value[j].attri_value_id+";";
            }
        }
        $("#attrTable").append('<tr><th class="col-6-1 text-c">'+attrObjCanch[i].attribute_name+'</th><td><span>'+attrValStr+'</span><a onclick="addAttr('+attrObjCanch[i].attribute_id+",'"+attrIdsStr+"'"+')">添加</a></td></tr>')
    }
    }else {
    for(var i=0;i<spuResult.attribute.length;i++){
        var attrValStr="";
        var attrIdsStr="";
        if(spuResult.attribute[i].value.length != 0){
            for(var j=0;j<spuResult.attribute[i].value.length;j++){
                attrValStr += spuResult.attribute[i].value[j].attri_value+";";
                attrIdsStr += spuResult.attribute[i].value[j].attri_value_id+";";
            }
        }
        $("#attrTable").append('<tr><th class="col-6-1 text-c">'+spuResult.attribute[i].attribute_name+'</th><td><span>'+attrValStr+'</span><a onclick="addAttr('+spuResult.attribute[i].attribute_id+",'"+attrIdsStr+"'"+')">添加</a></td></tr>')
    }
    }

    if(sessionStorage.getItem("spuImgCache")){
    var getSpuImgCache = sessionStorage.getItem("spuImgCache");
    var spuInfoImg = JSON.parse(getSpuImgCache)
    for(item in spuInfoImg) {
        if(spuInfoImg[item].imgSort == "1"){
            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg1" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId1" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl1" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox1" class="pt-10 updataBtn"><a onclick="editPic(1)" class="pd-20">修改</a><a onclick="deletePic(1)" class="pd-20">删除</a></div><div class="pd-20">排序<input type="text" class="input-text radius" onchange="checkRepeat(this, 1)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort1" name="imgSort"></div></div>')
        }if(spuInfoImg[item].imgSort == "2"){
            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg2" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId2" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl2" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox2" class="pt-10 updataBtn"><a onclick="editPic(2)" class="pd-20">修改</a><a onclick="deletePic(2)" class="pd-20">删除</a></div><div class="pd-20">排序<input type="text" class="input-text radius" onchange="checkRepeat(this, 2)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort2" name="imgSort"></div></div>')
        }if(spuInfoImg[item].imgSort == "3"){
            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg3" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId3" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl3" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox3" class="pt-10 updataBtn"><a onclick="editPic(3)" class="pd-20">修改</a><a onclick="deletePic(3)" class="pd-20">删除</a></div><div class="pd-20">排序<input type="text" class="input-text radius" onchange="checkRepeat(this, 3)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort3" name="imgSort"></div></div>')
        }if(spuInfoImg[item].imgSort == "4"){
            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg4" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId4" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl4" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox4" class="pt-10 updataBtn"><a onclick="editPic(4)" class="pd-20">修改</a><a onclick="deletePic(4)" class="pd-20">删除</a></div><div class="pd-20">排序<input type="text" class="input-text radius" onchange="checkRepeat(this, 4)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort4" name="imgSort"></div></div>')
        }if(spuInfoImg[item].imgSort == "5"){
            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg5" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[item].imgUrl+'\')" src="'+spuInfoImg[item].imgUrl+'" width="150" height="150"></span><span id="spuImgId5" style="display: none">'+spuInfoImg[item].imgId+'</span><span id="spuImgUrl5" style="display: none">'+spuInfoImg[item].imgUrl+'</span><div id="btnBox5" class="pt-10 updataBtn"><a onclick="editPic(5)" class="pd-20">修改</a><a onclick="deletePic(5)" class="pd-20">删除</a></div><div class="pd-20">排序<input type="text" class="input-text radius" onchange="checkRepeat(this, 5)" value="'+spuInfoImg[item].imgSort+'" id="spuImgSort5" name="imgSort"></div></div>');
            $(".addSpuImgbox").css({
                display:"none"
            })
        }
    }
    }else {
    var spuImgCache = {};
    var spuInfoImg = spuResult.spu_img;
    spuImgCount = spuInfoImg.length;
    for(var i = 0; i < spuInfoImg.length; i++){
        console.log(spuInfoImg[i].img_sort)
        if(spuInfoImg[i].img_sort == 1){
            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg1" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[i].img_url+'\')" src="'+spuInfoImg[i].img_url+'" width="150" height="150"></span><span id="spuImgId1" style="display: none">'+spuInfoImg[i].img_id+'</span><span id="spuImgUrl1" style="display: none">'+spuInfoImg[i].img_url+'</span><div id="btnBox1" class="pt-10 updataBtn"><a onclick="editPic(1)" class="pd-20">修改</a><a onclick="deletePic(1)" class="pd-20">删除</a></div><div class="pd-20"> 排序<input type="text" class="input-text radius" onchange="checkRepeat(this, 1)" value="'+spuInfoImg[i].img_sort+'" id="spuImgSort1" name="imgSort"></div></div>')
            spuImgCache["img1"] = {
                imgId: spuInfoImg[i].img_id,
                imgUrl: spuInfoImg[i].img_url,
                imgSort: spuInfoImg[i].img_sort
            }
        } else if(spuInfoImg[i].img_sort == 2){
            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg2" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[i].img_url+'\')" src="'+spuInfoImg[i].img_url+'" width="150" height="150"></span><span id="spuImgId2" style="display: none">'+spuInfoImg[i].img_id+'</span><span id="spuImgUrl2" style="display: none">'+spuInfoImg[i].img_url+'</span><div id="btnBox2" class="pt-10 updataBtn"><a onclick="editPic(2)" class="pd-20">修改</a><a onclick="deletePic(2)" class="pd-20">删除</a></div><div class="pd-20">排序<input type="text" class="input-text radius" onchange="checkRepeat(this, 2)" value="'+spuInfoImg[i].img_sort+'" id="spuImgSort2" name="imgSort"></div></div>')
            spuImgCache["img2"] = {
                imgId: spuInfoImg[i].img_id,
                imgUrl: spuInfoImg[i].img_url,
                imgSort: spuInfoImg[i].img_sort
            }
        } else if(spuInfoImg[i].img_sort == 3){
            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg3" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[i].img_url+'\')" src="'+spuInfoImg[i].img_url+'" width="150" height="150"></span><span id="spuImgId3" style="display: none">'+spuInfoImg[i].img_id+'</span><span id="spuImgUrl3" style="display: none">'+spuInfoImg[i].img_url+'</span><div id="btnBox3" class="pt-10 updataBtn"><a onclick="editPic(3)" class="pd-20">修改</a><a onclick="deletePic(3)" class="pd-20">删除</a></div><div class="pd-20">排序<input type="text" class="input-text radius" onchange="checkRepeat(this, 3)" value="'+spuInfoImg[i].img_sort+'" id="spuImgSort3" name="imgSort"></div></div>')
            spuImgCache["img3"] = {
                imgId: spuInfoImg[i].img_id,
                imgUrl: spuInfoImg[i].img_url,
                imgSort: spuInfoImg[i].img_sort
            }
        } else if(spuInfoImg[i].img_sort == 4){
            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg4" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[i].img_url+'\')" src="'+spuInfoImg[i].img_url+'" width="150" height="150"></span><span id="spuImgId4" style="display: none">'+spuInfoImg[i].img_id+'</span><span id="spuImgUrl4" style="display: none">'+spuInfoImg[i].img_url+'</span><div id="btnBox4" class="pt-10 updataBtn"><a onclick="editPic(4)" class="pd-20">修改</a><a onclick="deletePic(4)" class="pd-20">删除</a></div><div class="pd-20">排序<input type="text" class="input-text radius" onchange="checkRepeat(this, 4)" value="'+spuInfoImg[i].img_sort+'" id="spuImgSort4" name="imgSort"></div></div>')
            spuImgCache["img4"] = {
                imgId: spuInfoImg[i].img_id,
                imgUrl: spuInfoImg[i].img_url,
                imgSort: spuInfoImg[i].img_sort
            }
        }else if(spuInfoImg[i].img_sort == 5){
            $(".imgTable .imgboxUl").append('<div class="f-l ml-5"><span id="spuImg5" class="spu_add_img"><img onclick="picShow(\'查看图片\',\'picShow.html\',\''+spuInfoImg[i].img_url+'\')" src="'+spuInfoImg[i].img_url+'" width="150" height="150"></span><span id="spuImgId5" style="display: none">'+spuInfoImg[i].img_id+'</span><span id="spuImgUrl5" style="display: none">'+spuInfoImg[i].img_url+'</span><div id="btnBox5" class="pt-10 updataBtn"><a onclick="editPic(5)" class="pd-20">修改</a><a onclick="deletePic(5)" class="pd-20">删除</a></div><div class="pd-20">排序<input type="text" class="input-text radius" onchange="checkRepeat(this, 5)" value="'+spuInfoImg[i].img_sort+'" id="spuImgSort5" name="imgSort"></div></div>')
            spuImgCache["img5"] = {
                imgId: spuInfoImg[i].img_id,
                imgUrl: spuInfoImg[i].img_url,
                imgSort: spuInfoImg[i].img_sort
            }
            $(".addSpuImgbox").css({
                display:"none"
            })
        }
    }
    sessionStorage.setItem("spuImgCache", JSON.stringify(spuImgCache));
    }
    }
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
    //                alert(XMLHttpRequest);
    }
    });*/


    /*tab切换*/
    jQuery.Huitab = function (tabBar, tabCon, class_name, tabEvent, i) {
        var $tab_menu = $(tabBar);
        // 初始化操作
        $tab_menu.removeClass(class_name);
        $(tabBar).eq(i).addClass(class_name);
        $(tabCon).hide();
        $(tabCon).eq(i).show();

        $tab_menu.bind(tabEvent, function () {
            $tab_menu.removeClass(class_name);
            $(this).addClass(class_name);
            var index = $tab_menu.index(this);
            $(tabCon).hide();
            $(tabCon).eq(index).show()
        })
    }
    $(function () {
        $.Huitab("#tab_topnav .tabBar span", "#tab_topnav .tabCon", "current", "click", "0")
    });
    // #tab_demo 父级id
    // #tab_demo .tabBar span 控制条
    // #tab_demo .tabCon 内容区
    // click 事件 点击切换，可以换成mousemove 移动鼠标切换
    // 1	默认第2个tab为当前状态（从0开始）

    function cancleSpu() {
        var ind = parent.layer.getFrameIndex(window.name);
        layer.confirm('确认要取消吗？',function(index){
            parent.layer.close(ind);
            layer.msg('已取消', {icon: 6,time:1000});
        });
    }


</script>
</body>
</html>